<?php
function bend_prod(&$retparams){
	global $_db;
	
	if("addview"==$_POST['op']){
		echo rendertpl("applet/prodaddmod.applet", array("title"=>"添加案例"));
		return BEND_RENDERED;
	}
	elseif("add"==$_POST['op']){
		$id = $_db->insert("prod", array("name"=>@$_POST['name'],"desc"=>@$_POST['desc'],"orgid"=>@$_POST['orgid']));
		if($id>0){
			$retparams['errorcode'] = 0;
		}
		else{
			$retparams['errorcode'] = -1;
		}
		return BEND_ECHORET;
	}
	elseif("del"==$_POST['op']){
		$count = $_db->delete("prod", "id=$_POST[id]");
	}
	elseif("modview"==$_POST['op']){
		echo rendertpl("applet/prodaddmod.applet", array("title"=>"修改案例"));
		return BEND_RENDERED;
	}
	elseif("mod"==$_POST['op']){
		$count = $_db->update("prod", array("name"=>@$_POST['name'],"desc"=>@$_POST['desc'],"orgid"=>@$_POST['orgid']),"id=$_POST[id]");
		if($count>0){
			$retparams['errorcode'] = 0;
		}
		else{
			$retparams['errorcode'] = -1;
		}
		return BEND_ECHORET;
	}
	elseif("search"==$_POST['op']){
		return BEND_HOMEPAGE;
	}
	return BEND_REDIRECT;
}
?>